import React, { ReactElement, memo } from "react";

export type ThemeType = "dark" | "default";

export interface ISystemDto {
  activeKey?: string;
  theme: ThemeType;
}

export interface SystemDto {
  systemInfo: ISystemDto;
  setSystemInfo?: (fn: (v: ISystemDto) => ISystemDto) => void;
}
const SystemContext = React.createContext<SystemDto | null>(null);

export default SystemContext;

export const SystemProvider = memo(function SystemProvider(props: {
  value: SystemDto | null;
  children: ReactElement | ReactElement[];
}) {
  return (
    <SystemContext.Provider value={props.value}>
      {props?.children}
    </SystemContext.Provider>
  );
});
